package tmall.framework;

import lombok.Data;
import tmall.framework.code.StatusCode;

/**
 * @author wei
 * @version 1.0.0
 * @description
 * @createTime 2022年01月16日 17:02:00
 */
@Data
public class Response {

    private int code;
    private String msg;
    private Object data;

    public Response(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Response(StatusCode statusCode, Object data) {
        this.code = statusCode.getCode();
        this.msg = statusCode.getMsg();
        this.data = data;
    }

    public Response(StatusCode statusCode) {
        this.code = statusCode.getCode();
        this.msg = statusCode.getMsg();
    }

    public static Response of(StatusCode statusCode) {
        return new Response(statusCode);
    }

    public static Response of(StatusCode statusCode, Object data) {
        return new Response(statusCode, data);
    }
}
